package com.gupao.gupaoeduvippattern.javaBase.a2Collection.demo01;

import java.util.ArrayList;
import java.util.List;

public class Gather {

    public static void main(String[] args) {
        List<String> list = new ArrayList(-2);
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");

        String remove = list.remove(2);
        System.out.println("移除的元素："+remove);

        //获得随机下标
        double d = Math.random();
        int i = (int)(d * list.size());
        System.out.println("随机数："+d+",随机获取的元素：" + list.get(i));

        //遍历list集合
        for(int j=0; j<list.size(); j++){
            System.out.println(list.get(j));
        }


    }

}
